﻿using System.Data;
using System.Data.SqlClient;

namespace MyWeb.Data
{
    public class AdvertiseController : SqlDataProvider
    {
        #region [Advertise_GetByAll]

        public DataTable Advertise_GetByAll()
        {
            return GetDataTable("sp_Advertise_GetByAll");
        }

        #endregion

        #region [Advertise_GetById]

        public DataTable Advertise_GetById(int id)
        {
            var p1 = new SqlParameter("@id", id);
            return GetDataTable("sp_Advertise_GetById", p1);
        }

        #endregion

        #region [Advertise_GetByPositionStatus]

        public DataTable Advertise_GetByPositionStatus(int position,int status)
        {
            var p1 = new SqlParameter("@position", position);
            var p2 = new SqlParameter("@status", status);
            return GetDataTable("sp_Advertise_GetByPositionStatus", p1, p2);
        }

        #endregion

        #region [Advertise_Insert]

        public void Advertise_Insert(AdvertiseInfo advertise)
        {
            var p1 = new SqlParameter("@name", advertise.Name);
            var p2 = new SqlParameter("@url", advertise.Url);
            var p3 = new SqlParameter("@width", advertise.Width);
            var p4 = new SqlParameter("@height", advertise.Height);
            var p5 = new SqlParameter("@link", advertise.Link);
            var p6 = new SqlParameter("@target", advertise.Target);
            var p7 = new SqlParameter("@position", advertise.Position);
            var p8 = new SqlParameter("@order", advertise.Order);
            var p9 = new SqlParameter("@distribution_id", advertise.Distribution_Id);
            var p10 = new SqlParameter("@status", advertise.Status);
            ExecuteStoreProcedure("sp_Advertise_Insert", p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
        }

        #endregion

        #region [Advertise_Update]

        public void Advertise_Update(AdvertiseInfo advertise)
        {
            var p0 = new SqlParameter("@id", advertise.Id);
            var p1 = new SqlParameter("@name", advertise.Name);
            var p2 = new SqlParameter("@url", advertise.Url);
            var p3 = new SqlParameter("@width", advertise.Width);
            var p4 = new SqlParameter("@height", advertise.Height);
            var p5 = new SqlParameter("@link", advertise.Link);
            var p6 = new SqlParameter("@target", advertise.Target);
            var p7 = new SqlParameter("@position", advertise.Position);
            var p8 = new SqlParameter("@order", advertise.Order);
            var p9 = new SqlParameter("@distribution_id", advertise.Distribution_Id);
            var p10 = new SqlParameter("@status", advertise.Status);
            ExecuteStoreProcedure("sp_Advertise_Update", p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
        }

        #endregion

        #region [Advertise_Delete]

        public void Advertise_Delete(int id)
        {
            var p0 = new SqlParameter("@id", id);
            ExecuteStoreProcedure("sp_Advertise_Delete", p0);
        }

        #endregion

        #region [Advertise_ActiveStatus]

        public void Advertise_ActiveStatus(int id, int status)
        {
            var p1 = new SqlParameter("@id", id);
            var p2 = new SqlParameter("@status", status);
            ExecuteStoreProcedure("sp_Advertise_ActiveStatus", p1, p2);
        }

        #endregion
    }
}